AttributeError: 'list' object has no attribute 'lower'. How to fix the code in order to have it conv